    let data={
    promoterCode:'',
    alipayAccount:'',
    alipayName:'',
    createId:'',
    createTime:'',
    desensitizedAlipayAccount:'',
    desensitizedAlipayName:'',
    id:'',
    msgCode:'',
    phoneNum:'',
    phoneNumMd5:'',
}
    let phoneNumEnc
    let timer
    function toRecord(){
        window.location.href = 'record.html'
    }
    function back(){
        window.location.href = 'share.html'
    }
    function getDuanMa() {
        let phoneNumEnc = data.phoneNumMd5;
        $.ajax({
            type: 'GET',
            url: httpUrl+'/api/v1/open/bindWithdrawal?phoneNumEnc='+phoneNumEnc,
            success: function(result) {
                if(result.code=='10000'){
                    $(".duanMa").hide();
                    $(".duanMaGet").show();
                    var countdown = 59;  // 设置倒计时为 59 秒
                    if(timer){
                        clearTimeout(timer)
                    }
                    timer = setInterval(function() {
                        $(".duanMaGet").text("已发送(" + countdown + ")");
                        countdown--;
                        if (countdown < 0) {
                            clearInterval(timer);
                            $(".duanMa").show();
                            $(".duanMaGet").hide();
                        }
                    }, 1000);
                }else{
                    setTimeout(()=>{
                        alert(result.msg)
                    },50)
                }
    },
    error: function(xhr, status, error) {
    setTimeout(()=>{
    alert('发送失败，请稍后再试。');
},50)

}
});
    }
    function getData(){
        const storedData = localStorage.getItem('userData');
        data = JSON.parse(storedData);
        getPromoteInfo()
        const hasAlipayData = data.alipayName && data.alipayAccount;
        const trueClassElements = document.querySelectorAll('.true');
        const falseClassElements = document.querySelectorAll('.false');
        const nameElement = document.querySelector('.alipayName');
        const accountElement = document.querySelector('.alipayAccount');
        const phoneNum = document.querySelector('.phoneNum');
        const promoterCode = document.querySelector('.promoterCode');

        phoneNum.textContent = data.phoneNum;
        promoterCode.textContent = data.promoterCode;

        if (hasAlipayData) {
            trueClassElements.forEach(element => {
                element.style.display = 'inline'; // 显示为 inline
            });
            falseClassElements.forEach(element => {
                element.style.display = 'none';
            });
            nameElement.textContent = data.desensitizedAlipayName;
            accountElement.textContent = data.desensitizedAlipayAccount;
        } else {
            trueClassElements.forEach(element => {
                element.style.display = 'none';
            });
            falseClassElements.forEach(element => {
                element.style.display = 'inline';
            });
        }
    }
    function getPromoteInfo(){
    $.ajax({
        type: 'GET',  // 使用 GET 方法
        url: httpUrl + '/api/v1/open/promoteInfo?promoterCode=' + data.promoterCode,
        success: function(result) {
            if(result.code == '10000'){
                var promoteData = result.data;
                localStorage.setItem('PromoteInfo', JSON.stringify(result.data));
                for (var key in promoteData) {
                    if (promoteData.hasOwnProperty(key)) {
                        var spanElement = document.querySelector('.' + key);
                        if (spanElement) {
                            spanElement.textContent = promoteData[key];
                        }
                    }
                }
            } else {
                setTimeout(() => {
                    alert(result.msg);
                }, 50);
            }
        },
        error: function(xhr, status, error) {
            console.log(error);
        }
    });
}
    function allCashOut(){
        const realName = document.getElementById("alipayName").textContent.trim()
        const alipayAccount = document.getElementById("alipayAccount").textContent.trim()
        const smsCode = document.getElementById("duan").value.trim();
        if (!realName || !alipayAccount || !smsCode) {
            alert("请填入完整信息");
        } else {
            let params={
                msgCode:smsCode,
                id: data.id
            }
            var codeDiv = document.querySelector('.model');
            if (codeDiv.style.display !== 'none') {
                codeDiv.style.display = 'none';
            } else {
            codeDiv.style.display = 'block';
            }
            $.ajax({
                type: 'POST',
                url: httpUrl+'/api/v1/open/withdrawal',
                contentType: 'application/json',
                data: JSON.stringify(params),
                success: function(result) {
                    if(result.code=='10000'){
                        codeDiv.style.display = 'none';
                        setTimeout(()=>{
                            alert(result.msg)
                            getPromoteInfo()
                        },50)
                    }else{
                        codeDiv.style.display = 'none';
                        setTimeout(()=>{
                            alert(result.msg)
                        },50)

                    }

                },
                error: function(xhr, status, error) {
                    codeDiv.style.display = 'none';
                    setTimeout(()=>{
                        alert('网络波动，请稍后再试。');
                    },50)

                }
            });
        }
    }
    function toEdit(){
        window.location.href = 'edit.html'
    }
    getData()
